var status = 0;
var mmobs = Array(9500320, 100100, 100101, 120100, 130101, 130100, 210100, 9400505, 1210100, 9420001, 1210102, 1110101, 2130100, 9500167, 1210101, 1120100, 1210103, 1110100, 2100100, 2100101, 9600001, 9600002, 2230108, 5200000, 2230107, 9600003, 9420004, 9400547, 2230109, 9420000, 2230200, 2100108, 2110301, 9100013, 9600004, 9300134, 3100102, 9400518, 9300136, 3110300, 9600006, 9400509, 3210204, 5400000, 3230101, 3110302, 3210800, 3110303, 3230305, 3230308, 4230600, 9400563, 9500179, 4230107, 4230109, 4110300, 9300014);
var mmonster = 0;
var mhp = 0;
var exp = 0;

function start() {
    status = -1;
    action(1, 0, 0);
}
 
function action(mode, type, selection) {
    if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 0 && status == 0) {
            cm.dispose();
            return;
        }
        if (mode == 1)
            status++;
        else
            status--;
        if (status == 0) {
	var selStr = "Hello #h #, Welcome to #rChickenMS#k\r\nI am here to earn some money!\r\nPick the mob and i will unleash it!#b";
		for (var i = 0; i < mmobs.length; i++) {
			selStr += "\r\n#L" + i + "##o" + mmobs[i] + "#";
		}
                cm.sendSimple(selStr);
        } else if (status == 1) {
		mmonster = mmobs[selection];
		cm.sendGetText("How much HP must this monster have?\r\nThe minimum amount is 100\r\n#rfor abusing reasons is the maximum amount 10mil#k");
	} else if (status == 2) {
		mhp = cm.getText();
		exp = (mhp * 0.01);
		if (mhp >= 100 && mhp <= 10000000) {
			cm.sendOk("So you want to spawn a #o" + mmonster + "# with " + mhp + " hp for " + mhp + " mesos?");
		} else {
			cm.sendOk("This is an illegal amount of HP");
			cm.dispose();
		}
	} else if (status == 3) {
		if (cm.getMeso() >= mhp) {
			cm.spawnMob(mmonster, mhp, 1000, 1, exp, 0, 0, 1, 0, 0);
            		cm.gainMeso(-mhp);
			cm.dispose();
		} else {
			cm.sendOk("You dont have enough mesos");
			cm.dispose();
		}
	}
}
}